package com.example.wangzh.developkit.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.RecyclerView;

import com.example.wangzh.developkit.R;
import com.example.wangzh.developkit.databinding.ItemRcvTestBinding;
import com.example.wangzh.developkit.utils.UIUtils;
import com.example.wangzh.developkit.utils.ViewUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: zhwang37
 * @date: 2021/9/13 10:12
 * @email:zhwang37@iflytek.com
 * @describe:
 */
public class RcvTestAdapter extends RecyclerView.Adapter<RcvTestAdapter.ViewHolder> {
    public static final List<String> strList = new ArrayList<>();

    static {
        for (int i = 0; i < 3000; i++) {
            strList.add("" + i);
        }
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        ItemRcvTestBinding binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.item_rcv_test, parent, false);
        return new ViewHolder(binding.getRoot());
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        holder.itemView.setTag(position);
        holder.binding.txt.setText(strList.get(position));
    }

    @Override
    public int getItemCount() {
        return strList.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        ItemRcvTestBinding binding;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            binding = DataBindingUtil.getBinding(itemView);
        }
    }
}
